package com.version.manager.rabbitmq;

import com.version.manager.entity.Shop.shopCar;
import com.version.manager.service.Shop.shopCarService;
import com.version.manager.util.JsonUtil;
import com.version.manager.vo.shopCarInput;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class MQReceiver {
    @Autowired
    private shopCarService carService;
    @RabbitListener(queues = MQConfig.SHOP_CAR_QUEUE)

    public void receiveShopCar(String input){
        shopCarInput car= JsonUtil.json2Object(input,shopCarInput.class);
        carService.saveToDb(car.getCarItem());
    }

//    @RabbitListener(queues = MQConfig.QUEUE)
//    public void receive(Object message){
//        System.out.println("receive:");
//        System.out.println(message);
//    }
//
//    @RabbitListener(queues = MQConfig.TOPIC_QUEUE1)
//    public void receiveTopic1(Object message){
//        System.out.println("receiveTopic1:");
//        System.out.println(message);
//    }
//
//    @RabbitListener(queues = MQConfig.TOPIC_QUEUE2)
//    public void receiveTopic2(Object message){
//        System.out.println("receiveTopic2:");
//        System.out.println(message);
//    }
//
//    @RabbitListener(queues=MQConfig.HEADER_QUEUE)
//    public void receiveHeaderQueue(Object message) {
//        System.out.println("receiveHeaderQueue:");
//        System.out.println(message);
//    }
//
//    @RabbitListener(queues=MQConfig.HEADER_QUEUE)
//    public void receiveFanoutExchageQueue(Object message) {
//        System.out.println("receiveHeaderQueue:");
//        System.out.println(message);
//    }
}
